home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / networking / misc / parpc04.lha / hardware / src / DUMP.C next >
Encoding:
C/C++ Source or Header  |  1993-08-13  |  1.7 KB  |  67 lines

  1. /* DUMP.C: Test sending large amount of data from PC to amiga
  2.  * 1. on your amiga, type: machaddr 5
  3.  *                         get 4
  4.  * 2. on the PC, type:     dump 5 4
  5.  *
  6.  * When your interface & cables are ok, you will see dots appearing on the
  7.  * screen, each representing a packet successfully sent. After each 15th
  8.  * packet the number of Kbytes sent will be printed.
  9.  *
  10.  * (port & destination addresses can ofcourse be changed)
  11.  */
  12. #include <stdio.h>
  13. #include <signal.h>
  14. #include "pardev.h"
  15.  
  16. Header hdr;
  17.  
  18. /* length of data field in packet */
  19. #define PLENGTH 512
  20.  
  21. void ParAbort(void)
  22. {
  23.   par_stop();
  24.   printf("Aborted.\n");
  25.   exit(1);
  26. }
  27.  
  28. /* when writing are interrupts not really needed */
  29. int parint(int dev)
  30. {
  31. }
  32.  
  33. main(int argc,char **argv)
  34. {
  35.  unsigned int dest,port;
  36.  unsigned long count;              /* just some counter */
  37.  int length;                       /* actual number of bytes sent */
  38.  unsigned char buffer[PLENGTH];    /* buffer to be sent */
  39.  
  40.  par_init(1,LPTADDR);
  41.  ctrlbrk(ParAbort);                /* abort this program with CTRL-C */
  42.  
  43.  dest=atoi(argv[1]);
  44.  port=atoi(argv[2]);
  45.  
  46.  printf("Dumping data size %d to destination %d port %d\n",PLENGTH,dest,port);
  47.  
  48.  /* fill the PARnet header */
  49.  put16((char *)&hdr.port,port);
  50.  hdr.chksum = 0;
  51.  put32((char *)&hdr.length,PLENGTH);
  52.  
  53.  /* writing buffer to line */
  54.  for (count=1;count<65535;count++)     /* do this many times */
  55.  { 
  56.   length=parwriteV(dest,&hdr,sizeof(hdr),buffer,PLENGTH,NULL,NULL);
  57.   if (length < 0)
  58.     printf("ERROR %d\n",length);
  59.   else
  60.   { if (!(count & 15))
  61.          printf("WROTE %08lu %d KBYTES\n",count,count * PLENGTH /1024);
  62.     else printf(".");
  63.   }
  64.  }
  65.  ParAbort();
  66. }
  67.